#ifndef QDATAOPERATOR_H
#define QDATAOPERATOR_H

#include <QString>
#include <QVariant>

#include <QTimer>
#include <QDateTime>

class QDeviceManager;

struct tagDataInfo;

class QAbstractDataOperator: public QObject
{
    Q_OBJECT
public:
    QAbstractDataOperator(const QString &device_uuid,tagDataInfo* data,
                          QDeviceManager* device,int time=1000);
    ~QAbstractDataOperator();

    virtual bool edit(QWidget* parent);
protected slots:
    void run();
protected:
    virtual bool make_value();
protected:
   QString      m_device_uuid;
   QDeviceManager  *m_device_manager;
   tagDataInfo  *m_data;
   QTimer       *m_timer;
   QVariant     m_value;
   QDateTime    m_last_time;
   int          m_period;
};

class QStaticDataOPerator: public QAbstractDataOperator
{
public:
    QStaticDataOPerator(const QString &device_uuid,tagDataInfo* data,
                        QDeviceManager* device);
};

class QLinearIntOperator: public QAbstractDataOperator
{
public:
    QLinearIntOperator(const QString &device_uuid,tagDataInfo* data,
                          QDeviceManager* device);

    bool    edit(QWidget *parent);
protected:
    bool    make_value();

protected:
    int     m_step;
};

class QLinearFloatOperator: public QAbstractDataOperator
{
public:
    QLinearFloatOperator(const QString &device_uuid,tagDataInfo* data,
                          QDeviceManager* device);

    bool    edit(QWidget *parent);
protected:
    bool    make_value();

protected:
    float     m_step;
};

class QCustomOperator: public QAbstractDataOperator
{
public:
    QCustomOperator(const QString &device_uuid,tagDataInfo* data,
                          QDeviceManager* device);

    bool    edit(QWidget *parent);
protected:
    bool    make_value();
protected:
    QString m_code;
    int     m_count;
};

#endif // QDATAOPERATOR_H
